package com.drawingtimer.admin.handlers;

import com.drawingtimer.admin.exception.BizException;
import com.hccake.ballcat.common.model.result.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

	// 业务异常处理
	@ExceptionHandler(BizException.class)
	public R<Void> handleBizException(BizException ex) {
		return R.failed(ex.getCode(), ex.getMessage());
	}

	// 其他未捕获异常处理
	@ExceptionHandler(Exception.class)
	public R<Void> handleException(Exception ex) {
		return R.failed(500, "服务器内部错误：" + ex.getMessage());
	}

}
